# -*- coding: utf-8 -*-
"""
Created on Thu Jan  2 11:34:53 2025

@author: Administrator

description: 脚本用于处理销售数据
"""
import yaml
import requests

def read_config(config_file):
    """读取配置文件并返回配置数据"""
    try:
        with open(config_file, 'r', encoding='utf-8') as f:
            return yaml.safe_load(f)
    except FileNotFoundError:
        raise Exception(f"配置文件{config_file}不存在")
    except yaml.YAMLError as e:
        raise Exception(f"解析配置文件错误: {str(e)}")

CONFIG = read_config('config.yaml')
del_url = 'https://pos.meituan.com/web/api/v2/messages/deleted?yodaReady=h5&csecplatform=4&csecversion=3.2.1' # 店内通知
headers = {
    'Cookie':CONFIG['cookie'],
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0',
    'appCode': '49',
    'model': 'chrome'}
msg_list = CONFIG['msg_list'].split('\n')[:100]
data = {"messageIds": msg_list}
response = requests.post(del_url, headers=headers, json=data)
print(response.status_code)
print(response.text)